<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>登录</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
	<style type="text/css">
	.button{
    		background: transparent;
    		border: 0px none;
    		outline: none;
    		color: red;
    		font-size: 20;
    	}
</style>
	<script type=" text/javascript">
function loadXMLDoc(){
	var xmlhttp;
	if(window.XMLHttpRequest){
		xmlhttp=new XMLHttpRequest();
	}else{
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	return xmlhttp;
}
function jump() {
		var ajax;
		ajax = loadXMLDoc();
		ajax.open("POST", "loginservlet", true);
		ajax.onreadystatechange = function()  {
			if (ajax.readyState == 4 && ajax.status == 200) {
				var result = ajax.responseText;
				if (result == "true") {
					location.href = "supermarket.jsp";
				} else {
					document.getElementById("mypd").innerHTML = "用户名或密码错误";
				}
			}
		}
		ajax.setRequestHeader("Content-type",
				"application/x-www-form-urlencoded");
		var name = document.getElementById("username").value;
		var pwd = document.getElementById("password").value;
		ajax.send("username=" + name + "&password=" + pwd);
	}
	</script>
  </head>
  
  <body>
    	
    <div class="container">
	<div class="row clearfix">
		<div class="col-md-2 column">
		
		</div>
		<div class="col-md-6 column">
		<center>
		<br><br><br><br><br><br><br><br>
			 <h5>登录</h5>
			 <br>
			 </center>
			<form role="form" action="">
				<div class="form-group">
					 <label for="exampleInputEmail1">用户名</label><input type="text" class="form-control" id="username" name="username" />
				</div>
				<div class="form-group">
					 <label for="exampleInputPassword1">密码</label><input type="password" class="form-control" id="password" name="password" />
				</div>
				<button type="button" class="btn btn-default" onclick="jump()">登录</button>
				<input type="reset"  class="btn btn-default" value="重置" />
			</form>
			<div id="mypd">
		</div>
			<button value="注册" onclick="window.location='register.jsp'" class="button">没有帐号？点击注册</button>
			
		</div>
		<div class="col-md-4 column">
		</div>
	</div>
</div>

  </body>
</html>
